<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <title>Title</title>
    <!-- 新 Bootstrap5 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/css/bootstrap.min.css">
    <!-- 最新的 Bootstrap5 核心 JavaScript 文件 -->
    <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="container pt-5 col-md-8 ">
    <div class="row clearfix">
        <div class="col-md-12">
            <h1 class="text-muted">图书管理</h1>
        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <a href="${pageContext.request.contextPath}/book/ToAddBook" class="btn btn-outline-primary">增加书籍</a>
        </div>
        <div class="col-md-2">
            <span class="badge  alert alert-danger">${error}</span>
        </div>
        <div class="col-md-4">
            <form method="post" action="${pageContext.request.contextPath}/book/SelectByName" class="input-group mb-3">
                <input type="text" class="form-control" placeholder="Search" name="BookName">
                <button class="btn btn-success" type="submit">Go</button>
            </form>
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-md-12 column">
            <table class="table  table-hover">
                <thead>
                <tr>
                    <th>书籍编号</th>
                    <th>书籍名称</th>
                    <th>书籍数量</th>
                    <th>书籍详情</th>
                    <th>操作</th>
                </tr>
                </thead>
                <c:forEach var="book" items="${BookList}">
                    <tr>
                        <td>${book.bookID}</td>
                        <td>${book.bookName}</td>
                        <td>${book.bookCounts}</td>
                        <td>${book.detail}</td>
                        <td>
                            <a href="${pageContext.request.contextPath}/book/ToUpdateBook?bookId=${book.bookID}"
                               class="btn btn-primary btn-sm">修改</a>
                            <a type="button"  class="btn btn-primary btn-sm"
                               href="${pageContext.request.contextPath}/book/DeleteBook/${book.bookID}" onclick="mydelete()">删除
                            </a>
<%--                            <div class="modal fade" id="myModal">--%>
<%--                                <div class="modal-dialog">--%>
<%--                                    <div class="modal-content">--%>
<%--                                        <div class="modal-header">--%>
<%--                                            <h4 class="modal-title">删除书籍</h4>--%>
<%--                                            <button type="button" class="btn-close" data-bs-dismiss="modal"></button>--%>
<%--                                        </div>--%>
<%--                                        <div class="modal-body">--%>
<%--                                            确定要删除${book.bookID}吗?--%>
<%--                                        </div>--%>
<%--                                        <div class="modal-footer">--%>
<%--                                            <a class="btn btn-danger"--%>
<%--                                               href="${pageContext.request.contextPath}/book/DeleteBook/${book.bookID}">删除--%>
<%--                                            </a>--%>
<%--                                        </div>--%>
<%--                                    </div>--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                        </td>--%>
                    </tr>
                </c:forEach>
            </table>
        </div>
    </div>
</div>
<script>
    function mydelete() {
        var result = confirm("确定要删除吗？");
        if (result) {
            alert("删除成功！");
        } else {
            alert("你点击了取消！");
        }
    }
</script>
</body>
</html>
